package com.bw.liuyushan.mykotlin_firstmvptest.Utils

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import kotlin.properties.ReadOnlyProperty
import kotlin.Lazy as Lazy1

/**
 *MyKotlin_FirstMVPTest
 *file name is : RxJavaManager
 *created by Ender on 2021/9/14 19:55.
 *author : 刘雨杉
 *Describe:
 */
class RxJavaManager private constructor()  {
//旧
      companion object {
          const val BASE_URL = "http://www.qubaobei.com/"
          val instance : RxJavaManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){
              RxJavaManager()
          }
      }

    fun getRetrofit(): Retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(OkHttpClient()
            .newBuilder()
            .addInterceptor(HttpLoggingInterceptor()
            .setLevel(HttpLoggingInterceptor
            .Level.BODY))
            .build())
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .build()






}